<?php

namespace app\model\zs;

use think\Model;

class ZsMemberCouponSuit extends Model
{
    // 设置当前模型对应的完整数据表名称
    protected $table = 'member_coupon_suit';

    // 设置当前模型的数据库连接
    protected $connection = 'zs';

    // 领取状态，0正常，1不可领取
    const RECEIVE_STATUS_ON = 0;
    const RECEIVE_STATUS_OFF = 1;

    // 0：审核未通过 1：审核中 2：审核通过
    const STATUS_FAIL = 0;
    const STATUS_WAIT = 1;
    const STATUS_PASS = 2;

    public function getInfoAttr($value)
    {
        return array_filter(json_decode($value, true) ?: []);
    }

    public function setInfoAttr($value)
    {
        $arr = $this->arrQuote($value);
        return $arr ? json_encode($arr, JSON_UNESCAPED_UNICODE) : '';
    }

    public function couponSuitRels()
    {
        return $this->hasMany(ZsMemberCouponSuitRel::class, 'sid', 'sid');
    }
}
